<DOCTYPE html>
  <html lang="en">

  <head charset="UTF-8">
    <title></title>
  </head>

  <body>
    <script>
      function LinkList() {
        let head = null;
        let length = 0
        function Node(data) {
          let data = data;
          let next = null
        }

        LinkList.prototype.append = data => {
          let node = new Node(data)
          if (this.length == 0) {
            this.head = node;
          } else {
            let current = this.head;
            while (current.next != null) {
              current = current.next
            }
            current.next = node
          }
          this.length++;
        }

        LinkList.prototype.insert = (position, data) => {
          if (position < 0 || position > this.length) {
            return false
          }
          if (this.length == 0 || position == this.length) {
            this.apped(data);
          } else {
            let node = new Node(data);
            let current = this.head;
            let index = -1;
            while (++index < position) {
              current = current.next
            }
            node.next = current.next
            current.next = node
            this.length++;
          }
        }

        LinkList.prototype.get = position => {
          if (position < 0 || position > this.length || this.length == 0) {
            return null
          } else {
            let current = this.head;
            let index = -1
            while (++index < position) {
              current = current.next
            }
            return current.data
          }
        }

        LinkList.prototype.indexOf = data => {
          if (this.length == 0) {
            return -1
          } else {
            let current = this.head;
            let index = 0
            while (current.next != null) {
              if (current.data == data) {
                return index
              }
              index++;
              current = current.next;
            }
            return -1
          }
        }

        LinkList.prototype.update = (position, data) => {
          if (position < 0 || position > this.length || this.length == 0) {
            return false
          } else {
            let current = this.head;
            let index = -1
            while (++index < position) {
              current = current.next
            }
            current.data = data
          }
        }

        LinkList.prototype.removeAt = position => {
          if (position < 0 || position > this.length || this.length == 0) {
            return false
          } else {
            let current = this.head;
            if (position == 0) {
              this.head = current.next
            } else {
              let index = 0
              while (++index < position) {
                current = current.next
              }
              current.next = current.next.next
            }
            this.length--;
          }
        }

        LinkList.prototype.remove = () => {
          if (this.length == 0) {
            return false
          }
          if (this.length == 1) {
            this.head = null
          } else {
            let current = this.head;
            let index = 1
            while (++index < this.length) {
              current = current.next
            }
            current.next == null
          }
          this.length--;
        }
      }
    </script>
  </body>

  </html>